#include<iostream>
using namespace std;
int huiwen(int n) {
	int s = 0;
	while (n) {
		s = s * 10 + n % 10;
		n /= 10;
	}
	return s;
}
int main() {
	int m;
	cin >> m;
	for (int i = 0; i <= m; i++) {
		if (i == huiwen(i)) {
			cout << i << endl;
		}
	}
}